<?php

namespace App\Http\Controllers\Frontend\V10\Common;

use App\Models\DownloadCount;
use App\Models\SettingSource;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;

class DownloadLinkController extends Controller
{
    public function list(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'source_id' => 'required',
        ]);
        if ($validator->fails()) {
            return failed('渠道号必填');
        }
        $source_id = $request->get('source_id');
        $ip = $request->getClientIp();
        $links = SettingSource::where('source_id',$source_id)->select(['ios_path','android_path'])->first();
        DownloadCount::create(['ip'=>$ip,'source_id'=>$source_id]);
        return success($links);
    }
}
